import yaml


# 读取
def read_yaml(yaml_path):
    with open(yaml_path, encoding="utf-8") as f:
        value = yaml.safe_load(f)
        return value


# 写入
def wirte_yaml(yaml_path):
    with open(yaml_path, encoding="utf-8", mode="w") as f:
        # mode="a+"是追加
        data = {"teacher": [{"name": "百里"}, {"name": "白矾"}]}
        yaml.safe_dump(data, f, allow_unicode=True)


# 清空
# def clean_yaml(yaml_path):
#     with open(yaml_path, encoding="utf-8", mode="w") as f:
#         pass


if __name__ == '__main__':
    print(read_yaml("../testcases/test_api.yaml"))
    # wirte_yaml("../testcases/test_api.yaml")
